package com.lobov.run.hadoop;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class Test {

	public static void main(String[] args) {
		Configuration conf = new Configuration();
		FileSystem fs = null;
		try {
			fs = FileSystem.get(conf);
		} catch (IOException e) {
			e.printStackTrace();
		}

		Path inFile = new Path("/home/sanix/dev/fileInput");
		Path outFile = new Path("/home/sanix/fileOutput");

		try {
			if (!fs.exists(inFile))
				// printAndExit("Input file not found");
				System.out.println("Input file not found");
			if (!fs.isFile(inFile))
				// printAndExit("Input should be a file");
				System.out.println("Input should be a file");
			if (fs.exists(outFile))
				// printAndExit("Output already exists");
				System.out.println("Output already exists");
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("OK");
		
		try {
			FSDataInputStream in = fs.open(inFile);
			FSDataOutputStream out = fs.create(outFile);
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	
	}

}
